import {
	GridExpBarActionType,
	GridExpViewActionType,
	IParam,
	IGridExpViewAbility,
	IGridExpViewController,
	IGridExpViewStore,
	IGridExpBarAbility,
	IGridExpViewControllerParams,
} from '@/core/interface';
import { ExpViewController } from './exp-view-controller';

/**
 * 表格导航视图控制器
 *
 * @export
 * @class GridExpViewController
 * @extends {ExpViewController<GridExpViewActionType, IGridExpViewStore, IGridExpViewAbility>}
 * @implements {IGridExpViewController<IGridExpViewStore, IGridExpViewAbility>}
 */
export class GridExpViewController
	extends ExpViewController<
		GridExpViewActionType,
		IGridExpViewStore,
		IGridExpViewAbility
	>
	implements IGridExpViewController<IGridExpViewStore, IGridExpViewAbility>
{
	/**
	 * 获取树部件能力
	 *
	 * @protected
	 * @return {*}  {(IGridAbility | undefined)}
	 * @memberof GridViewController
	 */
	protected getMainCtrlAbility(): IGridExpBarAbility | undefined {
		const expbar = this.model.ctrls.find(
			(ctrl: IParam) => ctrl.controlType === 'GRIDEXPBAR'
		);
		return expbar
			? this.getSubAbility<IGridExpBarAbility>(expbar.name)
			: undefined;
	}
}
